﻿using FastEmit;
using System.Data;

namespace Test
{

    internal class Program
    {
        static async Task Main(string[] args)
        {
            string time = DateTime.Now.ToString();
            Console.WriteLine(TypeConverter.Get(typeof(DateTime),time));
            Console.WriteLine(TypeConverter.Get(typeof(DateTime?), time));
            Console.WriteLine(TypeConverter.Get(typeof(DateTimeOffset), time));
            Console.WriteLine(TypeConverter.Get(typeof(DateTimeOffset?), time));

            Console.WriteLine("==================");

            var a = new People();
            var accessor = FastEmitFactory.GetTypeAccessor(typeof(People));

            foreach (var item in accessor.MemberDict)
            {
                Console.WriteLine($"{item.Key}===>{item.Value}");
            }

            accessor.SetValue(a, "Id", "asdad");
            Console.WriteLine(a.Id);

            var pdel = FastEmitFactory.GetConstructorInvoker(typeof(People));
            var b = pdel.Invoke();

            accessor.SetValue(b, "Id", "asdad====");
            var aasad = accessor.GetValue(b, "Id");
            Console.WriteLine(aasad);

            var methodAccessor = FastEmitFactory.GetMethodAccessor(typeof(People));
            var ddd = methodAccessor.CallMethod(b, "AA");

            Console.WriteLine("Hello, World!");
        }
    }

    class People
    {
        public string Id { get; set; }

        public int Age { get; set; }

        public static void AA()
        {
            Console.WriteLine("我是AAA");
        }

    }
}